/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package olympicgameslogic;


import java.io.Serializable;
import java.util.Comparator;

/**
 *
 * @author 75
 */
public class Discipline implements Serializable, Comparable<Discipline> {

   private Modality modality;
   private String name;
   private ClassificationType cType;
   private LinkedList<DisciplineEvent> eventsList;
   private DISCIPLINETYPE type;

   @Override
   public int compareTo(Discipline o) {
//      Discipline d = (Discipline)o;
//      return (modality.getName().equalsIgnoreCase(o.getModality().getName()) && name == o.getName());
      
      throw new UnsupportedOperationException("Not supported yet.");
   }
   
   
      public static enum DISCIPLINETYPE {

      INDIVIDUAL, TEAM,
   };
      public static Discipline.DISCIPLINETYPE[] types = {Discipline.DISCIPLINETYPE.INDIVIDUAL,Discipline.DISCIPLINETYPE.TEAM };

   public Discipline() {
   }

   public Discipline(String discipline, Modality modality, ClassificationType cType, LinkedList<DisciplineEvent> eventsList, DISCIPLINETYPE type) {
      setModality(modality);
      setName(discipline);
      setcType(cType);
      setEventsList(eventsList);
      setDisciplineType(type);

   }
   
    public Discipline(String discipline, Modality modality, ClassificationType cType,  DISCIPLINETYPE type) {
      setModality(modality);
      setName(discipline);
      setcType(cType);
      setDisciplineType(type);
      eventsList = new LinkedList();

   }


   /**
    * @return the modality
    */
   public Modality getModality() {
      return modality;
   }

   /**
    * @return the name
    */
   public String getName() {
      return name;
   }

   /**
    * @return the cType
    */
   public ClassificationType getcType() {
      return cType;
   }

   /**
    * @return the eventsList
    */
   public LinkedList<DisciplineEvent> getEventsList() {
      return eventsList;
   }

   /**
    * @param modality the modality to set
    */
   public void setModality(Modality modality) {
      this.modality = modality;
   }

   /**
    * @param name the name to set
    */
   public void setName(String name) {
      this.name = name;
   }

   /**
    * @param cType the cType to set
    */
   public void setcType(ClassificationType cType) {
      this.cType = cType;
   }
   
   public void setDisciplineType(Discipline.DISCIPLINETYPE type){
      this.setType(type);
   }

   

   public void addEvent(DisciplineEvent disciplineEvent) {
      eventsList.add(disciplineEvent);
   }

   public DisciplineEvent getDisciplineEvent(DisciplineEvent.EVENTGENDER gender) {

      for (DisciplineEvent disciplineEvent : eventsList) {
	 if (disciplineEvent.getEventGender().equals(gender)) {
	    return disciplineEvent;
	 }

      }
      return null;
   }
   public DisciplineEvent getDisciplineEvent(String disciplineName , DisciplineEvent.EVENTGENDER gender) {

      for (DisciplineEvent disciplineEvent : eventsList) {
	 if (disciplineEvent.getEventGender().equals(gender) && disciplineEvent.getEventName().equalsIgnoreCase(disciplineName)) {
	    return disciplineEvent;
	 }

      }
      return null;
   }

  

   /**
    * @return the type
    */
   public DISCIPLINETYPE getType() {
      return type;
   }

   /**
    * @param eventsList the eventsList to set
    */
   public void setEventsList(LinkedList<DisciplineEvent> eventsList) {
      this.eventsList = eventsList;
   }

   /**
    * @param type the type to set
    */
   public void setType(DISCIPLINETYPE type) {
      this.type = type;
   }

   @Override
   public String toString() {
           return this.name +" / "+(this.type.equals(Discipline.DISCIPLINETYPE.INDIVIDUAL)? " I ":" T ") + " / " + this.cType;
   }
}
